package com.tiejun.ge.mvc.repository.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tiejun.ge.mvc.entity.bo.SystemConfigBO;
import com.tiejun.ge.mvc.entity.po.SystemConfigPO;
import com.tiejun.ge.mvc.mapper.SystemConfigMapper;
import com.tiejun.ge.mvc.repository.SystemConfigRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: springboot
 * @description: SystemConfigRepository实现类
 * @author: getiejun
 * @create: 2025-08-23 22:14
 **/

@Repository
public class SystemConfigRepositoryImpl extends ServiceImpl<SystemConfigMapper, SystemConfigPO> implements SystemConfigRepository {

    @Resource
    private SystemConfigMapper systemConfigMapper;

    @Override
    public List<SystemConfigBO> list(SystemConfigBO systemConfigBO) {
        LambdaQueryWrapper<SystemConfigPO> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(ObjectUtil.isNotNull(systemConfigBO.getItem()), SystemConfigPO::getItem, systemConfigBO.getItem());
        lambdaQueryWrapper.eq(ObjectUtil.isNotNull(systemConfigBO.getId()), SystemConfigPO::getId, systemConfigBO.getId());
        List<SystemConfigPO> systemConfigPOS = systemConfigMapper.selectList(lambdaQueryWrapper);
        return systemConfigPOS.stream().map(SystemConfigPO::toBO).collect(Collectors.toList());
    }
}
